package reverseLinkedList;

//https://leetcode.cn/problems/reverse-linked-list/
public class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode cur = head;
        while (cur != null) {
            ListNode ext = cur.next;
            cur.next = pre;
            pre = cur;
            cur = ext;
        }
        return pre;
    }
}
